# -*- coding: utf-8 -*-
import numpy as np
from PIL import ImageGrab
import cv2
from win32api import GetSystemMetrics
import time

bbox = (GetSystemMetrics(0)//5, GetSystemMetrics(1)//3, GetSystemMetrics(0)//1.3, GetSystemMetrics(1))

last_time = time.time()
while True:
    printscreen = np.array(ImageGrab.grab(bbox=bbox))
    printscreen = cv2.cvtColor(printscreen, cv2.COLOR_BGR2RGB)
    cv2.imshow('window123', printscreen)
    print('loop took {} seconds'.format(time.time() - last_time))
    last_time = time.time()
    if cv2.waitKey(25) & 0xFF == ord('q'):
        cv2.destroyAllWindows()
        break
